<?php
/**
 * Created by PhpStorm.
 * User: Cloud
 * Date: 2018/4/2
 * Time: 16:04
 */
?>

<!DOCTYPE html>
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>个人中心（user-manager）-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url();?>"/>
    <link rel="shortcut icon" href="public/images/favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>

    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
</head>
<body>
<div class="bg">
    <!--common - head -->
    <?php $this->load->view('common/header.php'); ?>
    <!--common - head end-->

    <div class="container mt30">
        <div class="my-center-container">

            <?php $this->load->view('member/personal_left.php'); ?>

            <div class="my-center-right">
                <p class="my-center-right-tit">修改密码</p>
                <div class="my-center-right-cont">
                    <div class="my-center-right-form-box" style="width:540px;">
                        <form class="layui-form  my-center-right-form workbench-detail-form" action="">
                            <div class="pop-add-address-box">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">旧   密   码 <em class="color-red">*</em></label>
                                    <div class="layui-input-block">
                                        <input type="password" id="password" name="password" lay-verify="title" autocomplete="off" placeholder="请输入旧密码"  class="layui-input">
                                    </div>
                                </div>
                                <!--旧   密   码-->

                                <div class="layui-form-item">
                                    <label class="layui-form-label">新   密   码<em class="color-red">*</em></label>
                                    <div class="layui-input-block">
                                        <input type="password" id="new_password" name="new_password" required placeholder="请设置新密码" autocomplete="off" class=" layui-input">
                                    </div>
                                </div><!--新   密   码-->
                                <div class="layui-form-item">
                                    <label class="layui-form-label">确认新密码<em class="color-red">*</em></label>
                                    <div class="layui-input-block">
                                        <input type="password" id="news_password" name="news_password" lay-verify="name" autocomplete="off" placeholder="请再次输入新密码"   class="layui-input">
                                    </div>
                                </div><!--确认新密码-->
                            </div>

                            <div class="btn-box1" style="width:435px; padding: 20px 0">
                                <a href="javascript:;" id="6666" class="btn-cancel">重置</a>
                                <a href="javascript:;" id="5555" class="btn-submit">确认修改</a>
                            </div>
                        </form>
                    </div>


                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('common/bottom.php'); ?>

<script type="text/javascript" src="public/js/jquery.min.js"></script>
<script src="public/js/layui/layui.js"></script>
<script type="text/javascript" src="public/js/index.js"></script>
<script type="text/javascript" src="public/js/owl.carousel.min.js"></script>

<script>
    layui.use(['element','form', 'layedit', 'laydate','upload'], function(){
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit;
        var $ = layui.jquery
            ,upload = layui.upload;

        //监听导航点击
        element.on('nav(demo)', function(elem){
            //console.log(elem)
//      layer.msg(elem.text());
        });
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: '/upload/'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
        var uploadInst2 = upload.render({
            elem: '#test2'
            ,url: '/upload/'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo2').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
        var uploadInst3 = upload.render({
            elem: '#test3'
            ,url: '/upload/'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo3').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
        });


    });
</script>
<script type="text/javascript">
    $('#5555').click(function () {
        var password = $('#password').val();
        
        if (password.length == 0) {
            layer.alert('请先输入原密码',function(){
                $('#password').focus();
                layer.closeAll();
            });
            return false;
        }
        var arr = new Array();  
        arr = password.split(" ");  
        if(arr.length != 1){  
            layer.alert('密码只能是字母，数字，常用符号的组合',function(){
                $('#password').focus();
                layer.closeAll();
            });
             return false;
        }

        var new_password = $('#new_password').val();
        if (new_password.length<6 || new_password.length>20) {
            layer.alert('新密码请输入6-20个字符',function(){
                $('#new_password').focus();
                layer.closeAll();
            });
            return false;
        }
        var arr = new Array();  
        arr = new_password.split(" ");  
        if(arr.length != 1){  
            layer.alert('密码只能是字母，数字，常用符号的组合',function(){
                $('#new_password').focus();
                layer.closeAll();
            });
             return false;
        }

        var news_password = $('#news_password').val();
        if (news_password != new_password) {
            layer.alert('两次输入的密码不一致',function(){
                $('#news_password').focus();
                layer.closeAll();
            });
            return false;
        }
        if (new_password == news_password) {
            $.ajax({
                type: "post",
                dataType: "json",
                url: "member/password_edit",
                data: {'new_password': new_password, 'password': password},
                success: function (data) {
                    // console.log(data);
                    if (data.code == 0) {
                        layer.alert(data.msg,function(){
                             window.location.reload();
                            layer.closeAll();
                        });
                    } else {
                        layer.alert(data.msg)
                    }
                }
            });

        } else {
            layer.msg('确认密码与新密码不同');
            // $('#new_password').after('确认密码与新密码不同')
        }

    });
    $('#6666').click(function () {
       $('#password').val("");
       $('#new_password').val("");
        $('#news_password').val("");

    })
</script>
</body>
</html>